const query = require("../db/query");

// 获取中国各省数据
const Getprovince = async () => {
    let sql = `select * from china where pid=0`
    return await query(sql)
}

// 获取中国省份下的市
const Getcity = async (params) => {
    let sql = `SELECT * FROM china WHERE Pid = (SELECT Id FROM china WHERE Name = '${params.name}');`
    return await query(sql)
}
// 获取中国市下的县
const Getcounty = async (params) => {
    let sql = `SELECT * FROM china WHERE Pid = (SELECT Id FROM china WHERE Name = '${params.name}');`
    return await query(sql)
}

module.exports = {
    Getprovince,//获取中国各省数据
    Getcity,//获取中国省份下的市
    Getcounty,//获取中国市下的县
}